package admin;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class DataPanel extends JPanel {

	String fields[]; 
	JLabel lab[];
	JTextField txt[];
	
	public void setData(String[] data){
		
		for(int i =0; i< fields.length;i++){
			txt[i].setText(data[i]);
		}
	}
	public String[] getData(){
		String data[] = new String[fields.length];
		
		for(int i = 0;i<fields.length;i++){
			data[i] = txt[i].getText();
		}
		
		
		return data;
	}
	
	public DataPanel(String[] _fields){
		fields = _fields;
		lab = new JLabel[fields.length];
		txt = new JTextField[fields.length];
		
		int linePix = 20;
		this.setLayout(null);
		
		for(int i =0; i<fields.length;i++, linePix+=40){
			
			lab[i] = new JLabel(fields[i]+":");
			txt[i] = new JTextField();
			
			lab[i].setBounds(20, linePix, 100, 25);
			txt[i].setBounds(130, linePix, 200, 25);
			this.add(lab[i]);
			this.add(txt[i]);	
		}
	}
}
